
const CracoLessPlugin = require('craco-less');
const CompressionPlugin = require('compression-webpack-plugin');
const path = require('path');


module.exports = {
	webpack: {
		alias: {
			'@': path.resolve(__dirname, 'src'),
			'@api': path.resolve(__dirname, 'src/api'),
			'@ts': path.resolve(__dirname, 'src/types'),
			'@pages': path.resolve(__dirname, 'src/pages'),
			'@views': path.resolve(__dirname, 'src/views'),
			'@store': path.resolve(__dirname, 'src/store'),
			'@router': path.resolve(__dirname, 'src/router'),
			'@utiles': path.resolve(__dirname, 'src/utiles'),
			'@components': path.resolve(__dirname, 'src/components'),
		},
    plugins: [
      new CompressionPlugin({
        algorithm: 'gzip', // 算法       
        test: new RegExp('\\.(js|css)$'), // 压缩 js 与 css
        threshold: 10240, // 只处理比这个值大的资源。按字节计算
        minRatio: 0.8 // 只有压缩率比这个值小的资源才会被处理
      })
    ]
	},
	plugins: [
		{
			plugin: CracoLessPlugin,
			options: {
				lessLoaderOptions: {
					lessOptions: {
						modifyVars: { '@primary-color': '#1DA57A' },
						javascriptEnabled: true,
					},
				},
			},
		},
	],
};
